package com.lry.rpc.netty.client;

import com.lry.protocol.RpcMessage;
import com.lry.util.PositiveAtomicCounter;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;


public class ClientCache {

    public final static PositiveAtomicCounter ID_GEN = new PositiveAtomicCounter();

    //<requestId,响应的结果报文>
    private static Map<Integer, RpcMessage> PENDING = new ConcurrentHashMap<>();


    public static RpcMessage removeRpcMessageByRequestId(int requestId){
        return PENDING.remove(requestId);
    }


    public static void putToPending(int requestId,RpcMessage response){
        PENDING.put(requestId,response);
    }


}
